<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class AddressBookRelateLabel extends Model
{
    protected $table = 'c_address_book_relate_labels';


    public function label()
    {
        return $this->hasOne('App\Models\AddressBookLabel','id','address_book_label_id');
    }
    
    /***
     * @param $filter
     * 获取用户的所有标签
     */
    public function getUserAddressBookLabel($filter)
    {
        $res = $this->where([['address_book_id', '=', $filter['address_book_id']]])->with(['label'])->get();
        if (!empty($res)) {
            return $res->toArray();
        }
        return [];
    }
}
